package com.myecl.poker.view;

import java.awt.Image;
import java.io.IOException;
import java.io.InputStream;

import javax.imageio.ImageIO;


import com.myecl.poker.rules.Card;

public class Images {
	private final static String ressourcePath = "/main/ressources/";
	private final static String cardsPath = "cards/";
	private final static String guiPath = "gui/";
	private final static String gif = ".gif";
	public static final Image BACKGROUND = getImage(guiPath + "background" + gif);
	public static final Image BUTTON = getImage(guiPath + "button" + gif);

	public static Image getCard(Card card) {
		String path = card != null ? 
				cardsPath + card.toFilename() + gif : 
				cardsPath + "b1fv" + gif;
		return getImage(path);
	}
		
	private static Image getImage(String path) {
		Image image = null;
    	try {  
    		InputStream input = Images.class.getResourceAsStream(ressourcePath + path);
    		image =  ImageIO.read(input);
         } catch (IOException ex) {
              ex.printStackTrace();
         }
    	return image;
	}

}
